'''
Created on 2017年3月16日

@author: Administrator
'''
#定义函数
from macpath import sep
def ask_ok(prompt, retries=4, reminder='Please try again!'):
    while True:
        ok = input(prompt)
        if ok in ('y', 'ye', 'yes'):
            return True
        if ok in ('n', 'no', 'nop', 'nope'):
            return False
        retries = retries - 1
        if retries < 0:
            raise ValueError('invalid user response')
        print(reminder)
#调用函数
# res = ask_ok('Do you really want to quit?',2)
# print(res)

# res1 = ask_ok('Do you really want to quit?')
# print(res1)

#keyword function use
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
    print("-- This parrot wouldn't", action, end=' ')
    print("if you put", voltage, "volts through it.")
    print("-- Lovely plumage, the", type)
    print("-- It's", state, "!")
    
parrot('12', state='test')

#任意参数
def concat(*args, sep="/"):
    return sep.join(args)
rsp=concat('test1','test2',sep='*')
print(rsp)

pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
pairs.sort(key=lambda pair: pair[2])
print(pairs)
